﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="text/javascript" th:src="@{/home/js/public.js}"></script>
</head>
<body>
	<div class="navigation-t">
		<div class="navigation-tl">
			当前位置：<a href="#" onclick="changeMain('home')">主页</a> > 计划管理
		</div>
	</div>
	<div class="project">
		<div class="project-padding">
			<div class="table-tool project-t">
				<div class="table-tool-btn">
					<div class="tool-btn" id="plan-add">
						<span class="add-icon"></span><a>新增</a>
					</div>
					<div class="tool-btn"   id="plan-edit">
						<span class="edit-icon"></span><a>编辑</a>
					</div>
					<div class="tool-btn"  id="plan-del"  >
						<span class="del-icon"></span><a>删除</a>
					</div>
					<div class="tool-btn" id="plan-category">
						<span class="plan-icon"></span><a>计划类别</a>
					</div>
				</div>
				<div class="table-tool-ser">
					<div class="tool-ser">
						<input type="text" class="form-control" placeholder="输入查询条件"
							id="search1" />
					</div>
					<div class="tool-btn" onclick="js_method()">
						<span class="ser-icon"></span><a>搜索</a>
					</div>
				</div>
			</div>
			<!--内容开始-->
			<div class="table-head">
				<table width="100%" align="center" cellpadding="0" cellspacing="0"
					border="0">
					<thead>
						<tr>
							<td width="4%"><input type="checkbox" /></td>
							<td width="6%">序号</td>
							<td style="display: none">id</td>
							<td width="18%">任务描述</td>
							<td width="18%">计划节点</td>
							<td width="18%">计划类别</td>
							<td width="18%">任务状态</td>
							<td width="18%">责任人</td>
						</tr>
					</thead>
					<tbody>
						<tr th:each="row,iterStat : ${rows}">
							<td ><input type="checkbox" name="select_item" /></td>
							<td th:text="${iterStat.count}">1</td>
							<td  name="id" th:text="${row.id}" style="display: none">id</td>
							<td th:text="${row.taskDescription}">描述</td>
							<td th:text="${row.planNode}">节点</td>
							<td th:text="${row.palnTypeName}">类别</td>
							<td th:text="${row.taskState}">状态</td>
							<td th:text="${row.userName}">admin</td>
						</tr>
					</tbody>
				</table>
			</div>
			<!--内容结束-->
			<!--分页开始-->
			<div class="multimedia-c">
				<ul class="pagination" id="pagination">
				</ul>
				<input type="hidden" id="PageCount" runat="server" /> <input
					type="hidden" id="PageSize" runat="server" value="5" /> <input
					type="hidden" id="countindex" runat="server" value="10" />
				<!--设置最多显示的页码数 可以手动设置 默认为4-->
				<input type="hidden" id="visiblePages" runat="server" value="4" />
			</div>
			<!--分页结束-->
		</div>
	</div>
<script src="home/js/HomePage.js" type="text/javascript"></script>
</body>
<script th:inline="javascript">  

/*<![CDATA[*/  
	$(function() {
		$('#plan-add').on('click', function(e) {
			e.preventDefault();
			var diag = new $.Zebra_Dialog({
				source : {
					'iframe' : {
						'id':'plan',
						'src' : 'plan-add.html?timestamp='+new Date().getTime(),
						'height' : 340,
					}
				},
				width : 600,
				title : '新增',
			    buttons:  [
			               {caption: '保存', callback: function() { 
			            		var validate=document.getElementById("plan").contentWindow.getData();
			            		  if(!validate){
			            			 return false;
			            		 }
			            	   var data= document.getElementById("plan").contentWindow.getDataJson("planForm");
			           		   var obj = JSON.stringify(data);
			       		     	AjaxWebTableInfo("/Plan/saveOrUpdate",data);
			                  }}
	                        ]
			});
		});
		$('#plan-edit').on('click', function(e) {
			e.preventDefault();
			if($('input[name="select_item"]:checked').length==1){
				var checkBoxs= $('input[name="select_item"]:checked').parent();
				var id=checkBoxs.parent().parent().find("[name='id']").text();
				
			
				var diag = new $.Zebra_Dialog({
					source : {
						'iframe' : {
							'id':'plan',
							'src' : 'edit/plan-edit.html?id='+id,
							'height' : 340,
						}
					},
					width : 600,
					title : '编辑',
				    buttons:  [
				               {caption: '保存', callback: function() { 
				            		var validate=document.getElementById("plan").contentWindow.getData();
				            		  if(!validate){
				            			 return false;
				            		 }
				            	   var data= document.getElementById("plan").contentWindow.getDataJson("planForm");
				           		   var obj = JSON.stringify(data);
				       		       AjaxWebTableInfo("/Plan/saveOrUpdate",data);
				                  }}
		                        ]
				});
				
				
				
			}else{
				 $.Zebra_Dialog('<div class="prompt"><div class="warning-icon"></div><div class="success-title">请选中一行!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
			}
		
		});
		
		$('#plan-del').on('click', function(e) {
			e.preventDefault();
			var checkBoxs= $('input[name="select_item"]:checked').parent();
			var ids=checkBoxs.parent().parent().find("[name='id']");
		    var  id="";
  		   for (var i=0;i<ids.length;i++)
			{
  				if(i<ids.length-1){
  					id += $(ids[i]).text()+",";
  				}else{
  					id += $(ids[i]).text();
  				}
			} 
  		   
  		 $.ajax({
		     type: "post",
		     dataType: "json",
		     url:"/Plan/dele" ,
		     data:{id:id},
		     success: function (data, status) {
		    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">删除成功!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
		  	    $("#frameReft").load("/operation/plan/1?timestamp="+new Date().getTime());
		     },
		     error: function (data) {
		    	 $.Zebra_Dialog('<div class="prompt"><div class="error-icon"></div><div class="success-title">删除失败!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
		     }
		 });
  		   
		 });
		
		   $('#plan-category').on('click', function(e) {
		        e.preventDefault();
		        var diag = new $.Zebra_Dialog({
		            source: {'iframe': {
		            	'id':'planCategory',
		                'src':'noPage/plan-category.html',
		                'height':400,
		            }},
		            width:600,
		            title:'计划类别',
		            buttons: ['关闭']
		        });
		    });
	})
	function AjaxWebTableInfo(url , obj){
		 $.ajax({
		     type: "post",
		     dataType: "json",
		     url: url,
		     data:obj,
		     success: function (data, status) {
		    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">保存成功!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
		  	    $("#frameReft").load("/operation/plan/1?timestamp="+new Date().getTime());
		     },
		     error: function (data) {
		    	 $.Zebra_Dialog('<div class="prompt"><div class="error-icon"></div><div class="success-title">保存失败!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
		     }
		 });	
	}
	/*]]>*/  
	
</script>	
	
<script th:inline="javascript">  
/*<![CDATA[*/  
     var total ="[[${total}]]";
    var pageNo ="[[${pageNo}]]"; 
    var  search=[[${search}]]
    $("#search1").val(search);
    $("#PageCount").val(total);
    loadpage(pageNo,"operation/plan/",$("#search1").val());
	function js_method(){
	  var search= $("#search1").val();
	  $("#frameReft").load("/operation/plan/1?timestamp="+new Date().getTime(),{'search': search});
	}
/*]]>*/  
</script>
</html>
